//package com.zyq.validation.configuration;
//
//import org.hibernate.validator.HibernateValidator;
//import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.validation.beanvalidation.SpringConstraintValidatorFactory;
//import javax.validation.Validation;
//import javax.validation.Validator;
//import javax.validation.ValidatorFactory;
//
//@Configuration
//public class ValidatorConfiguration {//本配置类可以让需要校验的字段一个一个校验，而不是全部字段一次性都校验
//    @Bean
//    public Validator validator(AutowireCapableBeanFactory springBeanFactory){
//        ValidatorFactory factory= Validation.byProvider(HibernateValidator.class)
//                .configure()//快速失败
//                .failFast(true)
//                //解决springboot依赖注入的问题
//                .constraintValidatorFactory(new SpringConstraintValidatorFactory(springBeanFactory))
//                .buildValidatorFactory();
//        return factory.getValidator();
//    }
//}
//
